<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>点击</button>
    <script>
        //1.call()
        var o = {
            name: 'andy'
        }

        function fn1(a, b) {
            console.log(this);
            console.log(a + b);
        };
        fn1.call(o, 1, 1);
        //2.apply()
        var o = {
            name: 'andy'
        }

        function fn(arr) {
            console.log(this);
            console.log(arr);
        };
        fn.call(o, ['pink']);
        var arr1 = [1, 2, 33, 55, 98];
        var max = Math.max.apply(Math, arr1);
        console.log(max);
        //3.bind()
        var o = {
            name: 'andy'
        }

        function fn2(a, b) {
            console.log(this);
            console.log(a + b);
        };
        var f = fn2.bind(o, 1, 3);
        f();
        //bind()不调用函数 可改变this指向
        var btn = document.querySelector('button');
        btn.onclick = function () {
            this.disabled = true;
            setInterval(function () {
                this.disabled = false;
            }.bind(this), 3000)
        }
    </script>
</body>

</html>